Skip to content

feat: Add type hints and validation to core utility modules #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ansschh
Copy link

@ansschh ansschh commented Aug 9, 2025

Adds type hints and validation to core utility modules for better IDE support and early bug detection.

Changes

  • tokenizer.py: Added return type hint to get_tokenizer()
  • generate.py: Added type hints and checkpoint path validation to main()
  • torch/utils.py: Added type hints to suppress_output()

- Add return type hint to get_tokenizer()
- Add type hints and checkpoint validation to generate.py main()
- Add parameter type hints to suppress_output() in torch/utils.py

Improves IDE support and catches potential bugs early.
def main(args: argparse.Namespace) -> None:
# Validate checkpoint path exists
checkpoint_path = Path(args.checkpoint)
if not checkpoint_path.exists():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of vllm this doesn't have to be a path though. Could you modify the check for this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkundel-openai thanks! vLLM now checks local files only when required...

- Only validate local file paths for torch/triton backends
- Allow vllm to use model identifiers without path validation
- Addresses reviewer feedback from dkundel-openai
@ansschh ansschh requested a review from dkundel-openai August 13, 2025 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants